<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* CRM in Setting */
class Crm extends Controller {
	function Crm(){
		if(!$this->session->userdata('user_id')){
			redirect($this->config->item('auth'));
		}
        $this->load->model('users');
	}
    
    function index(){
        $this->myprofile();
    }
	
	function myprofile()
	{
		$data = array(
                        'title'		=>	$this->lang->line('setting'),
                        'table'		=>	array(
                                                'value'				=>	$this->users->getData(),
                                                'pos'				=>	$this->users->getPos(),
                                                'group'				=>	$this->users->getGroup()
											 ),
                        'form'      =>  array('action'              =>$this->config->item('usr_stg_upd'),
                                              'action2'             =>$this->config->item('usr_pwd_upd')
                                              ),                            
						'content'	=> 	'form',
						'menu' 		=> 	array(
												'dashboard_active'	=>	$this->config->item('empty'),
												'contact_active'	=>	$this->config->item('empty'),
                                                'contactdna_active'	=>	$this->config->item('empty'),
												'activity_active'	=>	$this->config->item('empty'),
												'job_active'		=>	$this->config->item('empty'),
												'call_active'		=>	$this->config->item('empty'),
                                                'user_active'		=>	$this->config->item('empty'),
												'report_active'		=>	$this->config->item('empty'),
												'master_active'		=>	$this->config->item('empty'),
												'graphic_active'	=>	$this->config->item('empty'),
												'setting_active'	=>	$this->config->item('active'),
											 ),
						'tab'		=>	array(
												'tab1'				=>	$this->lang->line('my_profile'),
												'tab1_link'			=>	$this->config->item('list'),
												'tab1_active'		=>	$this->config->item('active'),
                                                'tab2'				=>	$this->lang->line(''),
												'tab2_link'			=>	$this->config->item(''),
												'tab2_active'		=>	$this->config->item(''),
                                                'tab3'				=>	'',
												'tab4'				=>	'',
												'tab5'				=>	'',
												'tab6'				=>	'',
												'tab7'				=>	'',
												'tab8'				=>	''
											 )			
					 );
		$this->load->vars($data);
		$this->load->theme('default');
	}
    
    function myupdateprofile(){
        if($this->input->post('save')){
            //$val=count($this->users->getCek());
            //if($val){
                $this->users->getUpdate();
                $this->session->set_flashdata('message','<span class="message success"><strong>Success</strong>message - '.$this->lang->line('m_update').'  </span>');
                redirect($this->input->server('HTTP_REFERER'));
             //}   
        }
        
    }
    
    function myupdatepassword(){
        if($this->input->post('save')){
            if(($this->input->post('oldpassword')== "") || ($this->input->post('password')== "") || ($this->input->post('password_confirm')== "") ){
                $this->session->set_flashdata('message2','<span class="message error"><strong> Error </strong>message - '.$this->lang->line('m_fpassword').'  </span>');
                redirect($this->input->server('HTTP_REFERER'));
            }
            
            if($this->input->post('password')<> $this->input->post('password_confirm')){
                $this->session->set_flashdata('message2','<span class="message error"><strong> Error </strong>message - '.$this->lang->line('m_cpassword').'  </span>');
                redirect($this->input->server('HTTP_REFERER'));
            }
            
            $val=count($this->users->getCekPassword());
            if($val >= 1){
                $this->users->getPassword();
                $this->session->set_flashdata('message2','<span class="message success"><strong> Success </strong>message - '.$this->lang->line('m_password').'  </span>');
                redirect($this->input->server('HTTP_REFERER'));
            }else{
                $this->session->set_flashdata('message2','<span class="message error"><strong> Error </strong>message - '.$this->lang->line('m_wpassword').'  </span>');
                redirect($this->input->server('HTTP_REFERER'));
            }
        }
    }

}

/* End of file dashboard.php */
/* Location: ./system/application/modules/matchbox/controllers/dashboard.php */